package Method;

import Book.Book;
import Book.BookList;
import java.util.Scanner;

//借阅图书
public class BrrowOperation implements IOperation{
    @Override
    public void work(BookList bookList) {
        Scanner sc = new Scanner(System.in);
        System.out.println("借阅图书：");
        System.out.println("请输入你要借阅的图书：");
        String name = sc.nextLine();

        for(int i=0;i< bookList.getBooksNum();i++){
            if(bookList.getBook(i).getName().equals(name)&&(!bookList.getBook(i).isBorrowed())){
                bookList.getBook(i).setBorrowed(true);
                System.out.println("借阅成功！");
                return ;
            }
        }

        System.out.println("借阅失败，未找到该图书，可能是已经被借出导致！");
    }
}
